package psobczuk.decorator;

public abstract class BoxUpgrade implements Box {
	
	private Box nextBox;
	private Item content;

	public BoxUpgrade() {
		
	}
	
	public BoxUpgrade( Box box ) {
		nextBox = box;
	}
	
	public void setContent(Item item) {
		if( nextBox != null ) {
			nextBox.setContent(item);
		}
		content = item;
	}

	public Item getContent() {
		return content;
	}

	public int getTotalWeight() {
		if( nextBox != null ) {
			return nextBox.getTotalWeight();
		} else {
			return getContent().getWeight();
		}
	}

	public int getBoxWeight() {
		if( nextBox != null ) {
			return nextBox.getBoxWeight();
		} else {
			return 0;
		}
	}

	public String describe() {
		if( nextBox != null ) {
			//return " + " + nextBox.describe();
			return nextBox.describe() + " + ";
		} else {
			return "";
		}
	}
}
